-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++] Use __alloc_traits in <deque> whenever it is available for consistency #126595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
03a0f0e to
76991ef
Compare
|
@llvm/pr-subscribers-libcxx Author: Peng Liu (winner245) ChangesWhen an allocator-aware container already defines a member type alias Full diff: https://github.com/llvm/llvm-project/pull/126595.diff 3 Files Affected:
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 95200b4801d7ff3..ce29286445d4c45 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -61,7 +61,7 @@ public:
deque& operator=(deque&& c)
noexcept((__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value);
+ __alloc_traits::is_always_equal::value);
deque& operator=(initializer_list<value_type> il);
template <class InputIterator>
@@ -133,7 +133,7 @@ public:
iterator erase(const_iterator p);
iterator erase(const_iterator f, const_iterator l);
void swap(deque& c)
- noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
+ noexcept(__alloc_traits::is_always_equal::value); // C++17
void clear() noexcept;
};
@@ -677,7 +677,7 @@ public:
_LIBCPP_HIDE_FROM_ABI deque& operator=(deque&& __c) noexcept(
(__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value);
+ __alloc_traits::is_always_equal::value);
_LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
# endif // _LIBCPP_CXX03_LANG
@@ -1382,7 +1382,7 @@ template <class _Tp, class _Allocator>
inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept(
(__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value) {
+ __alloc_traits::is_always_equal::value) {
__move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
return *this;
}
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 4b6ca8ea8587c08..79d144e6421064d 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -719,7 +719,7 @@ public:
_LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept(
(__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value);
+ __node_traits::is_always_equal::value);
_LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il);
@@ -1013,7 +1013,7 @@ template <class _Tp, class _Alloc>
inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(forward_list&& __x) noexcept(
(__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value) {
+ __node_traits::is_always_equal::value) {
__move_assign(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
return *this;
}
diff --git a/libcxx/include/list b/libcxx/include/list
index 3fcf796ebc03d04..9cdb7ffd78af02b 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -731,7 +731,7 @@ public:
_LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c) noexcept(
(__node_alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value);
+ __node_alloc_traits::is_always_equal::value);
_LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) {
assign(__il.begin(), __il.end());
@@ -1070,7 +1070,7 @@ template <class _Tp, class _Alloc>
inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
(__node_alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value) ||
- allocator_traits<allocator_type>::is_always_equal::value) {
+ __node_alloc_traits::is_always_equal::value) {
__move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());
return *this;
}
|
|
These changes are modifying stuff that was 1:1 standardese I think, so I'm not sure this change leads to any less "confusion". |
For deque, we were mixing For list and forward_list, we were mixing |
c304303 to
b98de1a
Compare
|
Just to be clear, I'm really ambivalent on whether we should make these changes. |
ldionne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion.
When an allocator-aware container already defines a member type alias
__alloc_traitsforstd::allocator_traits<allocator_type>, we should consistently use__alloc_traits. Mixing the usage of both__alloc_traitsandstd::allocator_traitscan lead to inconsistencies and confusion.The following are some specific instances from
dequewith mixed usages of__alloc_traitsandallocator_traits<allocator_type>:llvm-project/libcxx/include/deque
Lines 62 to 64 in 3e62321
llvm-project/libcxx/include/deque
Lines 678 to 680 in 3e62321
llvm-project/libcxx/include/deque
Lines 1383 to 1385 in 3e62321
This PR propose to consistently use
__alloc_traits.